
import numpy as np
from view.endSrc.One2OneDistance import One2OneDistance

class N2NDistances:

    def __init__(self):

        self.p2pDist = One2OneDistance()

    def __call__(self, dataPoints):
        n = dataPoints.shape[0]
        mat = np.zeros(shape=(n, n))  # Initialization matrix of dataPoints by dataPoints
        for i in range(n):
            for j in range(i+1, n):
                mat[i][j] = mat[j][i] = self.p2pDist(dataPoints[i], dataPoints[j])  # compute distance matrix

        return mat



    @staticmethod
    def testN2Ndistance():
        # dataPoints = np.matrix([[1,2,3],
        #                       [4,5,6],
        #                       [7,8,9]])
        dataPoints = np.matrix([[4, 5, 6],
                                [1, 2, 3],
                                [7, 8, 9]])
        dataMatrix = np.ones(shape=(dataPoints.shape[0], dataPoints.shape[0]))

        d = N2NDistances()
        dataMatrix = d(dataPoints)
        print(dataMatrix)

if __name__ == '__main__':
    N2NDistances.testN2Ndistance()


